package hr.ctg.domain.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;

@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Immutable
@Table(name = "valuta")
public class Valuta implements Serializable {
	@Id
	@Column(name = "id_valute")
	private int idValute;
	private String oznaka;
	private int jedinica;
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "valuta")
	private Set<VrijednostValute> vrijednostValuteCollection;

	private static final long serialVersionUID = 1L;

	public Valuta() {
		super();
	}

	public int getIdValute() {
		return idValute;
	}

	public void setIdValute(final int idValute) {
		this.idValute = idValute;
	}

	public String getOznaka() {
		return oznaka;
	}

	public void setOznaka(final String oznaka) {
		this.oznaka = oznaka;
	}

	public Set<VrijednostValute> getVrijednostValuteCollection() {
		return vrijednostValuteCollection;
	}

	public void setVrijednostValuteCollection(
			final Set<VrijednostValute> vrijednostValuteCollection) {
		this.vrijednostValuteCollection = vrijednostValuteCollection;
	}

	public void setJedinica(final int jedinica) {
		this.jedinica = jedinica;
	}

	public int getJedinica() {
		return jedinica;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + idValute;
		return result;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}

		final Valuta other = (Valuta) obj;
		if (idValute != other.idValute) {
			return false;
		}
		return true;
	}

}
